$().ready(function() {
	validateRule();
	var infoModelList;
	$.ajax({
		cache : true,
		type : "POST",
		url : "/jzweb/infoCollect/detailInfo",
		data : {id:$("#infoCollectId").val()},// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {

				var info="";
				infoModelList = data.data.infoModelList;
				var content = eval('('+data.data.infoCollect.content+')');

				infoModelList.forEach(function (item,index){
					if(item.type==0){
						info+="<div class='line'>"+item.name+"</div>";
					}else if(item.type==1 || item.type==2 || item.type==3){
						info+='<div class="form-group">' +
							'<label class="col-sm-3 control-label">' + item.name+ '：</label>' +
							'<div class="col-sm-8">' +
							'<input id="' + item.name + '" name="' + item.name + '" value="'+content[item.name] +'" class="form-control" type="text" readonly>' +
							'</div>' +
							'</div>';
					}else if(item.type==4){
						info+='<div class="form-group">' +
							'<label class="col-sm-3 control-label">' + item.name+ '：</label>' +
							'<div class="col-sm-8">' +
							'<a target="_blank" style="color: blue;line-height: 34px" download href="' + content[item.name] + '" >' + item.name + '</a>' +
							'</div>' +
							'</div>';
					}

				})
				$('#signupForm').html(info);
			} else {
				parent.layer.alert(data.msg)
			}

		}
	});
})

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/jzweb/infoCollect/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			}
		},
		messages : {
			name : {
				required : icon + "请输入名字"
			}
		}
	})
}